<template>
  <div id="AsnDetail">
    <div class="detail">
      <v-navMenu
        :detailNav="detailNav"
        :menuData="menuData"
        @setMentActive="setMentActive"
      ></v-navMenu>
      <component :inputData="detailData" :is="currentComponent"></component>
    </div>
  </div>
</template>

<script>
import detail from "commons/Detail";
import navMenu from "commons/NavMenu";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "Detail",
  mixins: [baseMixin],
  data() {
    return {
      flag: true,
      selectData: {},
      detailData: {},
      detailNav: "1",
      temporary: {},
      menuData: [
        { label: this.$t('out.OrdersTitle'), index: "1" },
        { label: this.$t("config.deliver"), index: "2" },
        { label: this.$t('out.bill'), index: "3" },
        { label: this.$t("config.other"), index: "4" },
        { label: this.$t("config.carrier"), index: "5" },
        { label: this.$t('out.load'), index: "6" },
        { label: this.$t('out.stateHistory'), index: "7" },
        { label: this.$t('out.pick'), index: "8" },
        { label: this.$t('out.taskDetail'), index: "9" },
        { label: this.$t('out.SowDetail'), index: "11" },
        { label: this.$t('out.CheckDetail'), index: "12" },
      ],
      componentConfig: [
        {
          name: "OrdersTitle",
          label: this.$t('out.OrdersTitle'),
          component: () => import("./page/OrdersTitle.vue"),
        },
        {
          name: "OrdersDelivery",
          label: this.$t("config.deliver"),
          component: () => import("./page/OrdersDelivery.vue"),
        },
        {
          name: "OrdersBill",
          label: this.$t('out.bill'),
          component: () => import("./page/OrdersBill.vue"),
        },
        {
          name: "other",
          label: this.$t("config.other"),
          component: () => import("./page/other.vue"),
        },
        {
          name: "OrdersCarrier",
          label: this.$t("config.carrier"),
          component: () => import("./page/OrdersCarrier.vue"),
        },
        {
          name: "OrdersLoad",
          label: this.$t('out.load'),
          component: () => import("./page/OrdersLoad.vue"),
        },
        {
          name: "OrdersStateHistory",
          label: this.$t('out.stateHistory'),
          component: () => import("./page/OrdersStateHistory.vue"),
        },
        {
          name: "OrdersPickDetail",
          label: this.$t('out.pick'),
          component: () => import("./page/OrdersPickDetail.vue"),
        },
        {
          name: "OrdersTaskDetail",
          label: this.$t('out.taskDetail'),
          component: () => import("./page/OrdersTaskDetail.vue"),
        },
        {
          name: "OrdersPickDetail_detail",
          label: this.$t('out.pickDetail'),
          component: () => import("./page/OrdersPickDetail_detail.vue"),
        },
        {
          name: "SowDetail",
          label: this.$t('out.SowDetail'),
          component: () => import("./page/SowDetail.vue"),
        },
        {
          name: "CheckDetail",
          label: this.$t('out.CheckDetail'),
          component: () => import("./page/CheckDetail.vue"),
        },
      ],
    };
  },
  computed: {
    currentComponent() {
      return this.componentConfig[this.detailNav - 1].component;
    },
  },
  methods: {
    setMentActive(key) {
      this.detailNav = key;
    },
    async getData() {
      try {
        let res = await this.$api.get(
          `/queryOrdersByOrdersKey/${this.selectData.orderkey}`
        );
        
          this.detailData = res.bean;
        
      } catch (e) {
        this.$message.error(e);
      }
    },
  },
  mounted() {
    let newFlag = this.$store.state.newFlag;
    //判断是否事新建
    if (newFlag) {
      this.detailData = {
        storerkey: "",
        allocatedonerp: "0",
        allowoverpick: 0,
        apportion: "0",
        batchflag: "0",
        billtokey: " ",
        bolnumber: " ",
        carrierroutestatus: "PENDING",
        consigneekey: " ",
        default1: " ",
        default2: " ",
        default3: " ",
        default4: " ",
        default5: " ",
        default6: " ",
        default7: " ",
        default8: " ",
        default9: " ",
        default10: " ",
        default11: " ",
        default12: " ",
        default13: " ",
        default14: " ",
        default15: " ",
        default16: " ",
        default17: " ",
        default18: " ",
        default19: " ",
        default20: " ",
        door: " ",
        enablepacking: "0",
        externalloadid: " ",
        externorderkey: "WMS0000032885",
        forte_flag: "1",
        freightcostamount: 0,
        intermodalvehicle: " ",
        item_number: 0,
        ohtype: "1",
        openqty: 0,
        orderbreak: "0",
        orderfinishflag: " ",
        ordergroup: " ",
        orderkey: "",
        ordervalue: 0,
        packinglocation: "PACK",
        priority: "5",
        rfidflag: "0",
        route: " ",
        rtxamtpaid: 0,
        rtxamtpayable: 0,
        rtxb_county: " ",
        rtxb_dest: " ",
        rtxbiznat: " ",
        rtxbsart: " ",
        rtxbuyermsg: " ",
        rtxc_county: " ",
        rtxc_dest: " ",
        rtxcancel: " ",
        rtxcancelmark: " ",
        rtxcancelreason: " ",
        rtxcancelwho: " ",
        rtxcbcode: " ",
        rtxcustomer: " ",
        rtxdctamt: 0,
        rtxdelmode: " ",
        rtxexpresskey: " ",
        rtxexpresskeyold: " ",
        rtxexternaltype: " ",
        rtxinsamt: 0,
        rtxinsamtrate: 0,
        rtxinsway: " ",
        rtxinterfacekey: " ",
        rtxinvprint: "N",
        rtxinvtitle: " ",
        rtxinvtype: " ",
        rtxpccode: " ",
        rtxpcname: " ",
        rtxpmtterm: " ",
        rtxpredistribution: "N",
        rtxpriority: " ",
        rtxsalesp: " ",
        rtxshippart: "N",
        rtxshopname: " ",
        rtxshortaddr: " ",
        rtxsjqloc: " ",
        rtxtotalamt: 0,
        rtxtxno: " ",
        rtxusername: " ",
        rtxvipreceiptkey: " ",
        rtxwaybillno: " ",
        shiptogether: "N",
        split_orders: "0",
        splitshipmentindicator: "0",
        spsapistrategykey: " ",
        stage: " ",
        status: "02",
        suspendedindicator: "0",
        susr1: "10",
        susr2: "10",
        totalcube: 0,
        totalgrosswgt: 0,
        totalorderlines: 0,
        totalqty: 1,
        type: "0",
        updatesource: "0",
      };
      this.detailData.orderkey = this.$store.state.routeId;
      this.detailData.externorderkey = "WMS" + this.$store.state.routeId;
    } else if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      this.detailData = data.detail;
      this.selectData = data.routeData;
      this.detailNav = data.detailNav;
    } else {
      this.selectData = this.$store.state.routeData;
      this.getData();
    }
  },
  components: {
    "v-detail": detail,
    "v-navMenu": navMenu,
  },
};
</script>

<style scoped></style>
